package cn.yeamin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.yeamin.one.mapper.OneAdminMapper;
import cn.yeamin.pojo.Admin;
import cn.yeamin.two.mapper.TwoAdminMapper;

/**
 * @classDesc: 功能描述:()
 * @author: 李彤
 * @createTime: 2017年6月29日 下午12:11:26
 * @version: v1.0
 * @copyright:奕明(上海)影视传媒有限公司
 */
@Service
@Transactional // 如果Service层try-Catch了,这个注解不能够回滚事务
public class AdminService {

	@Autowired
	private OneAdminMapper oneMapper;
	@Autowired
	private TwoAdminMapper twoMapper;

	public void add() {
		// try {
			Admin admin = new Admin();
			admin.setUserName("wangcai");
			admin.setRealName("旺财");
			admin.setPassword("123456");
			oneMapper.add(admin);
		int i = 1 / 0; // 模拟异常
			admin.setRealName("小强");
			admin.setPassword("888888");
			admin.setUserName("xiaoqiang");
			twoMapper.add(admin);
		// } catch (Exception e) {
		// e.printStackTrace();
			    
		// }
	}
}
